package com.zl.tby.icc;

import com.zl.tby.core.base.util.ToolsUtil;
import com.zl.tby.model.TbyCarRecord;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * 车辆抓拍记录
 * @author changpeng
 * @version 1.0
 * @since 2024/9/19 10:25
 */
@Data
public class IccCarRecord {
    /**主键id*/
    private Long id;
    /**设备编号*/
    private String devId;
    /**设备名称*/
    private String devName;
    /**车牌*/
    private String carNum;
    /**车速*/
    private BigDecimal carSpeed;
    /**车型编码*/
    private Integer carType;
    /**车型*/
    private String carTypeStr;
    /**行车方向*/
    private String carDirect;
    /**抓图日期*/
    private String capDateStr;
    /**图片路径*/
    private String carImgUrl;
    /**经度*/
    private String mapX;
    /**纬度*/
    private String mapY;

    public static TbyCarRecord convert(IccCarRecord data) {
        TbyCarRecord entity = new TbyCarRecord();
        entity.setId(data.getId());
        entity.setDeviceCode(data.getDevId());
        entity.setDeviceName(data.getDevName());
        entity.setCarNum(data.getCarNum());
        entity.setCarSpeed(data.getCarSpeed());
        entity.setCarType(data.getCarType());
        entity.setCarTypeStr(data.getCarTypeStr());
        entity.setCarDirect(data.getCarDirect());
        entity.setCapDate(ToolsUtil.dateString2Util(data.getCapDateStr(), "yyyy-MM-dd HH:mm:ss"));
        entity.setCarImgUrl(data.getCarImgUrl());
        entity.setLon(data.getMapX());
        entity.setLat(data.getMapY());
        entity.setDeleteFlag(0);
        entity.setCreateBy(-1L);
        entity.setCreateTime(LocalDateTime.now());
        return entity;
    }
}
